﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "session变量保存登录用户信息";

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (this.txtName.Text.Trim() != "" || this.txtPwd.Text.Trim() != "")
        {
            if (this.txtName.Text == "user" && this.txtPwd.Text == "123456")
            {
                Session["UserName"] = this.txtName.Text.Trim();
                Response.Redirect("SessionVariableWelcome.aspx?pwd=" + this.txtPwd.Text);
            }
            else
            {
                Session["UserName"] = "";
                RegisterStartupScript("Check", "<Script language='JavaScript'>alert('用户名或密码不对，请检查！');</Script>");
            }
        }
        else
        {
            Session["UserName"] = "";
        }

    }
}
